<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Meatball 聚合支付中心</title>
    <!-- ICON -->
    <link href="/meatball/images/meatball.ico" type="image/ico" rel="shortcut icon">
    <!-- CSS -->
    <link rel="stylesheet" href="/lib/layuiadmin/layui/css/layui.css" media="all" />
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row" th:object="${result.data}">
        <div class="layui-col-xs12" >
            <span th:text="*{outTradeNo}"></span>
        </div>
        <div th:if="*{payMethod == 'alipay'}" th:utext="*{form}"></div>
    </div>
</div>

<!-- JavaScript -->
<script type="text/javascript" src="/lib/layuiadmin/layui/layui.js"></script>
<!-- javascirpt -->
<script th:inline="javascript">
var data = [[${result.data}]];
</script>
<script type="text/javascript" th:inline="none">
layui.config({
    base: '/lib/layuiadmin/' //静态资源所在路径
}).extend({
    index: 'lib/index' //主入口模块
}).use('index', function() {
    var $ = layui.jquery;
    if(data.payMethod === "wxpay") {
        function onBridgeReady() {
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId":"wx40497ea3e158ce9b",     //公众号名称，由商户传入
                    "timeStamp":"1395712654",         //时间戳，自1970年以来的秒数
                    "nonceStr":"e61463f8efa94090b1f366cccfbbb444", //随机串
                    "package":"prepay_id=u802345jgfjsdfgsdg888",
                    "signType":"MD5",         //微信签名方式：
                    "paySign":"70EA570631E4BB79628FBCA90534C63FF7FADD89" //微信签名
                },
                function(res){
                    if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                        // 使用以上方式判断前端返回,微信团队郑重提示：
                        //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                    }
                });
        }
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        }else{
            onBridgeReady();
        }
    }
})
</script>
</body>
</html>